import { cloudService } from './index'
import { IAnniversary } from '@/types/anniversary'
import { IStatsChart } from 'vue3-common/types'

export const addAnniversaryApi = (anniversary: IAnniversary): Promise<boolean> =>
  cloudService({
    url: '/home-api/anniversary',
    method: 'post',
    data: anniversary
  })

export const updateAnniversaryApi = (id: number, anniversary: IAnniversary): Promise<boolean> =>
  cloudService({
    url: `/home-api/anniversary/${id}`,
    method: 'put',
    data: anniversary
  })

export const deleteAnniversaryApi = (id: number): Promise<boolean> =>
  cloudService({
    url: `/home-api/anniversary/${id}`,
    method: 'delete'
  })

export const queryAnniversaryApi = (category: string): Promise<IAnniversary[]> =>
  cloudService({
    url: '/home-api/anniversary',
    method: 'get',
    params: { category }
  })

export const queryAnniversaryCategoryApi = (): Promise<IStatsChart[]> =>
  cloudService({
    url: '/home-api/anniversary/category',
    method: 'get'
  })
